package de.tabuma.shopping.view;

import de.tabuma.lib.tabumaview;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.util.logging.*;

/**
 *
 * @author $Author: alefen $
 * @version $Revision: 1.2 $
 * @since $Date: 2009/07/21 19:37:33 $
 */
public class licenseAgreement extends tabumaview {

    private static Logger log =  Logger.getLogger(licenseAgreement.class.getName());

    String orderNav;
    public licenseAgreement(String servlet, Hashtable parameter, String orderNav) {
        super(servlet, parameter);
        this.orderNav = orderNav;
    }

    public void processRequest(ServletContext context, HttpServletRequest request, HttpServletResponse response, PrintWriter out)  {
        try {
            out.println("<div class=\"contentContent\">");
            out.println("<p class=\"contentContentHeader\">"+de.tabuma.shopping.constants.getValueFromProperties("orders.licenseagreement.head")+"</p>");
            out.println(de.tabuma.shopping.constants.getValueFromProperties("orders.licenseagreement.content"));
            out.println("</div>");

            String all = "";
            String preambleHead = de.tabuma.shopping.constants.getValueFromProperties("orders.licenseagreement.preamble.head");
            String preambleContent = de.tabuma.shopping.constants.getValueFromProperties("orders.licenseagreement.preamble.content");
            all += preambleHead+"\n\n"+preambleContent+"\n\n\n";
            String definitionsHead = de.tabuma.shopping.constants.getValueFromProperties("orders.licenseagreement.definitions.head");
            String definitionsContent1 = de.tabuma.shopping.constants.getValueFromProperties("orders.licenseagreement.definitions.content1");
            String definitionsContent2 = de.tabuma.shopping.constants.getValueFromProperties("orders.licenseagreement.definitions.content2");
            String definitionsContent3 = de.tabuma.shopping.constants.getValueFromProperties("orders.licenseagreement.definitions.content3");
            String definitionsContent4 = de.tabuma.shopping.constants.getValueFromProperties("orders.licenseagreement.definitions.content4");
            String definitionsContent5 = de.tabuma.shopping.constants.getValueFromProperties("orders.licenseagreement.definitions.content5");
            String definitionsContent6 = de.tabuma.shopping.constants.getValueFromProperties("orders.licenseagreement.definitions.content6");
            String definitionsContent7 = de.tabuma.shopping.constants.getValueFromProperties("orders.licenseagreement.definitions.content7");
            String definitionsContent8 = de.tabuma.shopping.constants.getValueFromProperties("orders.licenseagreement.definitions.content8");
            all += definitionsHead+"\n\n"+definitionsContent1+"\n\n"+definitionsContent2+"\n\n"+definitionsContent3+"\n\n"+definitionsContent4+"\n\n"+definitionsContent5+"\n\n"+definitionsContent6+"\n\n"+definitionsContent7+"\n\n"+definitionsContent8+"\n\n\n";
            String grantOfLicenseHead = de.tabuma.shopping.constants.getValueFromProperties("orders.licenseagreement.grantoflicense.head");
            String grantOfLicenseContent = de.tabuma.shopping.constants.getValueFromProperties("orders.licenseagreement.grantoflicense.content");
            all += grantOfLicenseHead+"\n\n"+grantOfLicenseContent+"\n\n\n";
            String limitationOfLiabilityHead = de.tabuma.shopping.constants.getValueFromProperties("orders.licenseagreement.limitationofliability.head");
            String limitationOfLiabilityContent = de.tabuma.shopping.constants.getValueFromProperties("orders.licenseagreement.limitationofliability.content");
            all += limitationOfLiabilityHead+"\n\n"+limitationOfLiabilityContent+"\n\n\n";
            String juristicationHead = de.tabuma.shopping.constants.getValueFromProperties("orders.licenseagreement.juristication.head");
            String juristicationContent = de.tabuma.shopping.constants.getValueFromProperties("orders.licenseagreement.juristication.content");
            all += juristicationHead+"\n\n"+juristicationContent+"\n\n\n";
            String serverabilityClauseHead = de.tabuma.shopping.constants.getValueFromProperties("orders.licenseagreement.serverabilityclause.head");
            String serverabilityClauseContent = de.tabuma.shopping.constants.getValueFromProperties("orders.licenseagreement.serverabilityclause.content");
            all += serverabilityClauseHead+"\n\n"+serverabilityClauseContent+"\n\n\n";

            String agreement = de.tabuma.shopping.constants.getValueFromProperties("orders.licenseagreement.licenseagreement");
            String finishOrder = de.tabuma.shopping.constants.getValueFromProperties("orders.licenseagreement.button.finishorder");


            String licenseErrorMessage = (String) request.getAttribute("orderLicenseErrorMessage");
            if(licenseErrorMessage!=null) {
                if(!licenseErrorMessage.equals("")) {
                    out.println("<div class=\"contentContent\">");
                    out.println("<div class=\"errormessage\">");
                    out.println("<div class=\"errormessage1\">"+licenseErrorMessage+"</div>");
                    out.println("</div>");
                    out.println("</div>");
                }
            }


            out.println("<div class=\"contentContent\">");
            out.println("<div class=\"orderLicenseAgreementTextarea\">");
            out.println("<textarea class=\"orderLicenseAgreementTextarea\" name=\"AgreementText\">"+all+"</textarea>");
            out.println("</div>");
            out.println(this.getFormBeginn(null));
            out.println(this.getHiddenAsAttribute());
            out.println("<input type=\"hidden\" name=\""+orderNav+"\" value=\""+de.tabuma.shopping.constants.ORDERNAV_LICENSEAGREEMENT+"\"/>");
            out.println("<div class=\"orderLicenseAgreementCheckbox\">");
            out.println("<input type=\"checkbox\" value=\"true\" name=\"Agreement\"/>"+agreement);
            out.println("</div>");
            out.println("<input type=\"submit\" value=\""+finishOrder+"\" class=\"loginbutton\"/>");
            out.println("</div>");
        } 
        catch(Exception e) {
            log.warning(e.getMessage());
        }
    }
    
}
